package com.example.mapstuct.enums;

import lombok.Getter;

/**
 * @author Lisicheng
 */
@Getter
public enum SexEnum {

    /**
     * 性别枚举
     */
    MALE(1, "男"),
    FEMALE(2, "女");

    SexEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private int code;

    private String desc;

    public static SexEnum getSexEnumByCode(int code) {

        for (SexEnum sexEnum : SexEnum.values()) {
            if (sexEnum.getCode() == code) {
                return sexEnum;
            }
        }
        return null;

    }

}
